<template>
    <div class="main-box">
        <el-button type="primary" @click="exportPdf">导出PDF</el-button>
        <div id="main-box">
            <div class="title">WNV风险评估报告</div>
            <div class="pdf-box">
                <div class="sub-title">1、风险评估材料与方法</div>
                <div class="content">
                    <div class="th-title">1.1、风险评估原理：</div>
                    <span class="zw">占位</span>传播媒介和传染源的活动数量是分析我国西尼罗热病毒输入风险的关键因素，本系统主要基于①西尼罗热传播媒介（蚊媒、候鸟）的活动数量和②全球西尼罗热发病数量（人）进行西尼罗热输入风险的模型计算分析。<br/>
                    <span class="zw">占位</span>通过地区的温度和湿度等变化因素对地区的蚊媒和候鸟的活动数量进行模型测算。通过统计分析不同时期内全球西尼罗热发病数量对病毒传染源进行模型测算。进一步根据风险评估模型综合分析我国地区性的潜在西尼罗热输入风险。<br/>
                    <span class="zw">占位</span>西尼罗热的流行除了受到蚊媒和候鸟（传播媒介）的影响，还受到生态、地理、宿主活动等各种因素的影响。本系统版本主要基于传播媒介数量和传染源数量进行模型分析，其余因素以模型参数和权重参数的形式纳入分析。<br/>
                    <span class="zw">占位</span>本系统主要针对有候鸟途径的我国西部部分地区。根据文献报道和本研究团队的实验分析，我国西部部分地区具有潜在的西尼罗热输入风险，并且与候鸟-蚊媒活动数量呈正相关。
                </div>
                <div class="content">
                    <div class="th-title">1.2、数据来源：</div>
                    <span class="zw">占位</span>《全球传染病疫情概要》<br/>
                    <span class="zw">占位</span>《中央气象台》、《中国天气网》<br/>
                    <span class="zw">占位</span>《国家地理信息公共服务平台》<br/>
                </div>
                <div class="content">
                    <div class="th-title">1.3、模型算法：</div>
                    <span class="zw">占位</span>根据文献El Moustaid, F., and Johnson, L.R. (2019). Modeling 蚊媒数量 Effects on Population Density of the Dengue Mosquito. Insects 10. ARTN 393 10.3390/insects10110393. 改进的传染病学中蚊媒和候鸟数量计算数学模型<br/>
                </div>
                <div class="sub-title">2、风险评估数据</div>
                <div class="content">
                    <div class="th-title">2.1、计算蚊媒数量</div>
                    <div id="charts1" style="height: 500px;width: 100%;margin: 20px 0;"></div>
                    <div id="charts2" style="height: 500px;width: 100%;margin: 20px 0;"></div>
                    <div id="charts3" style="height: 500px;width: 100%;margin: 20px 0;"></div>
                </div>
                <div class="content">
                    <div class="th-title">2.2、西尼罗热风险计算</div>
                    <el-table
                        :data="tableData"
                        border
                        style="width: 100%">
                        <el-table-column
                            prop="project"
                            label="项目"
                            align="center">
                        </el-table-column>
                        <el-table-column
                            prop="number"
                            label="计算数值"
                            align="center"
                            width="180">
                        </el-table-column>
                        <el-table-column
                            prop="score"
                            align="center"
                            width="180"
                            label="计分">
                        </el-table-column>
                    </el-table>
                </div>
                <div class="sub-title">3、风险评估说明</div>
                <div class="content">
                    <span class="zw">占位</span>根据模型测算，{{thisYear}}年{{thisMonth}}月我国西部地区的蚊媒数量约为{{thisMonthWm}}，候鸟数量约为{{thisMonthHn}}。同时期全球可统计的西尼罗热发病病例数为{{thisMonthBl}}；经本模型计算，该月的西尼罗热输入风险分数为{{thisMonthScore}}。<br/>
                    <span class="zw">占位</span>与同年其他月份相比，{{thisMonth}}月的蚊媒{{afterWmStr.length > 0 ? '数量低于'+ afterWmStr +'月，' : ''}}{{beforeWmStr.length > 0 ? '高于'+ beforeWmStr +'月，' : ''}} 数量排在第{{monthWmSeq}}位；候鸟{{afterHnStr.length > 0 ? '数量低于'+ afterHnStr +'月，' : ''}}{{beforeHnStr.length > 0 ? '高于' + beforeHnStr + '月，' : ''}}数量排在第{{monthHnSeq}}位；全球西尼罗热发病病例{{afterBlStr.length > 0 ? '数低于'+ afterBlStr +'月，' : ''}}{{afterBlStr.length > 0 ? '高于'+ afterBlStr +'月，' : ''}}数量排在第{{monthBlSeq}}位；经综合计算，西尼罗热输入风险分数{{afterScoreStr.length > 0 ? '低于'+ afterScoreStr +'月，' : ''}}{{beforeScoreStr.length > 0 ? '高于'+ beforeScoreStr +'月，' : ''}}排在第{{monthScoreSeq}}位；说明{{thisMonth}}月是西尼罗热输入风险较{{beforeScoreStr.length > afterScoreStr ? '高' : '低'}}的月份；<br/>
                    <span class="zw">占位</span>与往年同月份相比，{{thisYear}}年{{thisMonth}}月的蚊媒{{yearMonthWmBefore.length > 0 ? '数量低于'+ yearMonthWmBefore +'年，' : ''}}{{yearMonthWmAfter.length > 0 ? '高于'+ yearMonthWmAfter +'年，' : ''}}数量排在第{{yearMonthWmSeq}}位；候鸟{{yearMonthHnBefore.length > 0 ? '数量高于'+ yearMonthHnBefore +'年，' : ''}}{{yearMonthHnAfter.length > 0 ? '低于'+ yearMonthHnAfter +'年，' : ''}}数量排在第{{yearMonthHnSeq}}位；全球西尼罗热发病病例数{{yearMonthBlBefore.length > 0 ? '低于'+ yearMonthBlBefore +'年，' : ''}}{{yearMonthBlAfter.length > 0 ? '高于'+ yearMonthBlAfter +'年，' : ''}}数量排在第{{yearMonthBlSeq}}位；经综合计算，{{thisYear}}年西尼罗热输入风险分数{{yearMonthScoreBefore.length > 0 ? '高于'+ yearMonthScoreBefore +'年，' : ''}}{{yearMonthScoreAfter.length > 0 ? '高于'+ yearMonthScoreAfter +'年，' : ''}}排在第{{yearMonthScoreSeq}}位；说明{{thisYear}}年{{thisMonth}}月是西尼罗热输入风险较高/中/低的月份；<br/>
                </div>
                <div class="content" style="margin-top: 20px;">
                    <el-table
                        :data="tableDataYear"
                        border
                        style="width: 100%">
                        <el-table-column
                            prop="month"
                            label="月份"
                            width="180"
                            align="center">
                        </el-table-column>
                        <el-table-column
                            prop="wm"
                            label="蚊媒数量"
                            align="center"
                            width="180">
                        </el-table-column>
                        <el-table-column
                            prop="hn"
                            align="center"
                            width="180"
                            label="候鸟数量">
                        </el-table-column>
                        <el-table-column
                            prop="bl"
                            label="西尼罗热发病数"
                            align="center"
                            width="180">
                        </el-table-column>
                        <el-table-column
                            prop="fx"
                            align="center"
                            width="180"
                            label="西尼罗热输入风险计分">
                        </el-table-column>
                    </el-table>
                    <span class="zw">占位</span>根据模型测算，{{thisYear}}年我国西部地区的蚊媒数量约为{{totalWm}}，候鸟数量约为{{totalHn}}。同时期全球可统计的西尼罗热发病病例数为{{totalBl}}；经本模型计算，{{thisYear}}年的西尼罗热输入风险分数为{{totalScore}}（每月数值相加）。<br/>

                    <span class="zw">占位</span>与往年相比，{{thisYear}}年的西尼罗热输入风险分数{{yearScoreBefore.length > 0 ? '低于'+ yearScoreBefore +'年，' : ''}}{{yearScoreAfter.length > 0 ? '高于'+ yearScoreAfter +'年，' : ''}}排在第{{yearScoreSeq}}位；其中蚊媒{{this.yearWmAfter.length > 0 ? '数量低于'+ yearWmAfter +'年，' : ''}}{{this.yearWmBefore.length > 0 ? '高于'+ yearWmBefore +'年，' : ''}}排在第{{yearWmSeq}}位；候鸟数量{{yearHnAfter.length > 0 ? '低于'+ yearHnAfter +'年，' : ''}}{{yearHnBefore.length > 0 ? '高于'+ yearHnBefore +'年，' : ''}}排在第{{yearHnSeq}}位；全球西尼罗热发病病例数{{yearBlBefore.length > 0 ? '低于'+ yearBlBefore +'年，' : ''}}{{yearBlAfter.length > 0 ? '高于'+ yearBlAfter +'年，' : ''}}排在第{{yearBlSeq}}位；<br/>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import * as echarts from "echarts";
import {htmlToPdf} from "@/utils/print";

export default {
    name: 'PDFEXPORT',
    components: {},
    data() {
        return {
            tableData: [],
            tableDataYear: [],
            monthList: [],
            wdList: [],
            jslList: [],
            wmslList: [],
            hnslList: [],
            blslList: [],
            maxWd: 0,
            maxJsl: 0,
            maxWm: 0,
            maxHn: 0,

            wnvResult: 0,
            thisMonthHn: 0,
            thisMonthWm: 0,
            thisMonthBl: 0,
            thisMonthScore: 0,
            thisMonth: "",
            thisYear: "",

            totalWm: 0,
            totalHn: 0,
            totalBl: 0,
            totalScore: 0,


            // 排序情况
            wmslData: [],
            hnslData: [],
            blslData: [],
            scoreData: [],
            beforeHnStr: "",
            beforeWmStr: "",
            beforeBlStr: "",
            beforeScoreStr: "",
            afterWmStr: "",
            afterHnStr: "",
            afterBlStr: "",
            afterScoreStr: "",
            monthHnSeq: 0,
            monthWmSeq: 0,
            monthBlSeq: 0,
            monthScoreSeq: 0,

            yearWmSeq: 0,
            yearWmBefore: "",
            yearWmAfter: "",
            yearBlSeq: 0,
            yearBlBefore: "",
            yearBlAfter: "",
            yearHnSeq: 0,
            yearHnBefore: "",
            yearHnAfter: "",
            yearScoreSeq: 0,
            yearScoreBefore: "",
            yearScoreAfter: "",

            yearMonthWmSeq: 0,
            yearMonthWmBefore: "",
            yearMonthWmAfter: "",
            yearMonthBlSeq: 0,
            yearMonthBlBefore: "",
            yearMonthBlAfter: "",
            yearMonthHnSeq: 0,
            yearMonthHnBefore: "",
            yearMonthHnAfter: "",
            yearMonthScoreSeq: 0,
            yearMonthScoreBefore: "",
            yearMonthScoreAfter: "",
        }
    },
    activated() {
        this.init();


    },
    methods: {
        exportPdf(){
            htmlToPdf("WNV风险评估报告","main-box", "WNV")
        },
        addZero(num){
            if(num < 10){
                return "0" + num;
            }else{
                return  '' + num;
            }
        },

        init(){
            this.tableData = [];
            this.tableDataYear = [];
            this.monthList = [];
            this.wdList = [];
            this.jslList = [];
            this.wmslList = [];
            this.hnslList = [];
            this.blslList = [];
            // 年度相比
            this.$http({
                url: this.$http.adornUrl(`/admin/wnv/expWnvReportByYear`),
                method: 'post',
                data: this.$http.adornData({
                    wnvMonthBeg: "",
                    wnvMonthEnd: "",
                    wvnCurrentMonth: "",
                    wnvIndexCodes:  ["hnsl","wmsl","wnv"],
                    wnvLevel: "",
                    wnvIndexCode: ""
                })
            }).then(({ data }) => {
                console.log("🚀 ~ data", data)
                let wmData = data.filter((item) => {
                    return item.indexDesc === "蚊媒数量"
                })
                wmData.forEach((item) => {
                    item.indexOptions = Number(item.indexOptions)
                })
                wmData = wmData.sort(wfy.sortBy('indexOptions'))
                console.log("🚀 ~ wmData", wmData)
                let wmResult = this.getSeqYear(wmData);
                console.log("🚀 ~ wmResult", wmResult)
                this.yearWmSeq = wmResult.monthWmSeq;
                this.yearWmBefore = wmResult.beforeWmStr;
                this.yearWmAfter = wmResult.afterWmStr;

                let hnData = data.filter((item) => {
                    return item.indexDesc === "候鸟数量"
                })
                hnData.forEach((item) => {
                    item.indexOptions = Number(item.indexOptions)
                })
                hnData = hnData.sort(wfy.sortBy('indexOptions'))
                console.log("🚀 ~ hnData", hnData)
                let hnResult = this.getSeqYear(hnData);
                console.log("🚀 ~ hnResult", hnResult)
                this.yearHnSeq = hnResult.monthWmSeq;
                this.yearHnBefore = hnResult.beforeWmStr;
                this.yearHnAfter = hnResult.afterWmStr;

                let blData = data.filter((item) => {
                    return item.indexDesc === "全球WNV病例数量"
                })
                blData.forEach((item) => {
                    item.indexOptions = Number(item.indexOptions)
                })
                blData = blData.sort(wfy.sortBy('indexOptions'))
                console.log("🚀 ~ blData", blData)
                let blResult = this.getSeqYear(blData);
                console.log("🚀 ~ blResult", blResult)
                this.yearBlSeq = blResult.monthWmSeq;
                this.yearBlBefore = blResult.beforeWmStr;
                this.yearBlAfter = blResult.afterWmStr;

                let yearScoreData = [];
                blData.forEach((item) => {
                    let blslMonth = blData.find((bl) => {
                        return item.wnvYear === bl.wnvYear && bl.indexDesc === "全球WNV病例数量"
                    })
                    let hnslMonth = hnData.find((bl) => {
                        return item.wnvYear === bl.wnvYear && bl.indexDesc === "候鸟数量"
                    })
                    let wmslMonth = wmData.find((bl) => {
                        return item.wnvYear === bl.wnvYear && bl.indexDesc === "蚊媒数量"
                    })
                    console.log("🚀 ~ blslMonth", blslMonth)
                    console.log("🚀 ~ hnslMonth", hnslMonth)
                    console.log("🚀 ~ wmslMonth", wmslMonth)
                    let score = Number(blslMonth.wnvResult || 0) + Number(hnslMonth.wnvResult || 0) + Number(wmslMonth.wnvResult || 0);
                    yearScoreData.push({
                        wnvYear: item.wnvYear,
                        score: score.toFixed(2)
                    })
                })
                console.log("🚀 ~ yearScoreData1111111111111", yearScoreData)
                yearScoreData = yearScoreData.sort(wfy.sortBy('score'))
                console.log("🚀 ~ yearScoreData", yearScoreData)
                let scoreResult = this.getSeqYear(yearScoreData);
                console.log("🚀 ~ scoreResult", scoreResult)
                this.yearScoreSeq = scoreResult.monthWmSeq;
                this.yearScoreBefore = scoreResult.beforeWmStr;
                this.yearScoreAfter = scoreResult.afterWmStr;
            })
            console.log("🚀 ~ sessionStorage.wnvPdfMonth.substring(5,8)", sessionStorage.wnvPdfMonth.substring(5,8))
            // 每年的月份相比
            this.$http({
                url: this.$http.adornUrl(`/admin/wnv/expWnvReportByMonth`),
                method: 'post',
                data: this.$http.adornData({
                    wnvMonthBeg: "",
                    wnvMonthEnd: "",
                    wvnCurrentMonth: sessionStorage.wnvPdfMonth.substring(5,8),
                    wnvIndexCodes:  ["hnsl","wmsl","wnv"],
                    wnvLevel: "",
                    wnvIndexCode: ""
                })
            }).then(({ data }) => {
                console.log("🚀 ~ 全部年的某个月data", data)
                let wmData = data.filter((item) => {
                    return item.indexDesc === "蚊媒数量"
                })
                wmData.forEach((item) => {
                    item.indexOptions = Number(item.indexOptions)
                })
                wmData = wmData.sort(wfy.sortBy('indexOptions'))
                console.log("🚀 ~ wmData", wmData)
                let wmResult = this.getSeqMonth(wmData);
                console.log("🚀 ~ wmResult月度", wmResult)
                this.yearMonthWmSeq = wmResult.monthWmSeq;
                this.yearMonthWmBefore = wmResult.beforeWmStr;
                this.yearMonthWmAfter = wmResult.afterWmStr;

                let hnData = data.filter((item) => {
                    return item.indexDesc === "候鸟数量"
                })
                hnData.forEach((item) => {
                    item.indexOptions = Number(item.indexOptions)
                })
                hnData = hnData.sort(wfy.sortBy('indexOptions'))
                console.log("🚀 ~ hnData", hnData)
                let hnResult = this.getSeqMonth(hnData);
                console.log("🚀 ~ hnResult月度", hnResult)
                this.yearMonthHnSeq = hnResult.monthWmSeq;
                this.yearMonthHnBefore = hnResult.beforeWmStr;
                this.yearMonthHnAfter = hnResult.afterWmStr;

                let blData = data.filter((item) => {
                    return item.indexDesc === "全球WNV病例数量"
                })
                blData.forEach((item) => {
                    item.indexOptions = Number(item.indexOptions)
                })
                blData = blData.sort(wfy.sortBy('indexOptions'))
                console.log("🚀 ~ blData", blData)
                let blResult = this.getSeqMonth(blData);
                console.log("🚀 ~ blResult月度", blResult)
                this.yearMonthBlSeq = blResult.monthWmSeq;
                this.yearMonthBlBefore = blResult.beforeWmStr;
                this.yearMonthBlAfter = blResult.afterWmStr;

                let monthScoreData = [];
                blData.forEach((item) => {
                    let blslMonth = blData.find((bl) => {
                        return item.wnvMonth === bl.wnvMonth && bl.indexDesc === "全球WNV病例数量"
                    })
                    let hnslMonth = hnData.find((bl) => {
                        return item.wnvMonth === bl.wnvMonth && bl.indexDesc === "候鸟数量"
                    })
                    let wmslMonth = wmData.find((bl) => {
                        return item.wnvMonth === bl.wnvMonth && bl.indexDesc === "蚊媒数量"
                    })
                    console.log("🚀 ~ blslMonth2222", blslMonth)
                    console.log("🚀 ~ hnslMonth2222", hnslMonth)
                    console.log("🚀 ~ wmslMonth2222", wmslMonth)
                    let score = Number(blslMonth.wnvResult || 0) + Number(hnslMonth.wnvResult || 0) + Number(wmslMonth.wnvResult || 0);
                    monthScoreData.push({
                        wnvYear: item.wnvYear.substring(0,4),
                        score: score.toFixed(2)
                    })
                })
                console.log("🚀 ~ monthScoreData", monthScoreData)
                monthScoreData = monthScoreData.sort(wfy.sortBy('score'))
                console.log("🚀 ~ monthScoreData", monthScoreData)
                let scoreResult = this.getSeqYear(monthScoreData);
                console.log("🚀 ~ scoreResult", scoreResult)
                this.yearMonthScoreSeq = scoreResult.monthWmSeq;
                this.yearMonthScoreBefore = scoreResult.beforeWmStr;
                this.yearMonthScoreAfter = scoreResult.afterWmStr;
            })
            // 查询指定日期内
            this.$http({
                url: this.$http.adornUrl(`/admin/wnv/expWnvReportByMonth`),
                method: 'post',
                data: this.$http.adornData({
                    wnvMonthBeg: sessionStorage.wnvPdfMonth.substring(0,4) + "-01",
                    wnvMonthEnd: sessionStorage.wnvPdfMonth,
                    wnvIndexCode: "",
                    wnvLevel: ""
                })
            }).then(({ data }) => {
                console.log('🚀 ~ 指标列表', data)

                let month = new Date().getMonth() + 1;
                console.log(month);
                let wdList = data.filter((item) => {
                    return item.indexDesc === "温度";
                })
                let jslList = data.filter((item) => {
                    return item.indexDesc === "降水量";
                })
                let wmslList = data.filter((item) => {
                    return item.indexDesc === "蚊媒数量";
                })
                let hnslList = data.filter((item) => {
                    return item.indexDesc === "候鸟数量";
                })
                let blList = data.filter((item) => {
                    return item.indexDesc === "全球WNV病例数量";
                })
                let fxList = [];
                for (let i = 0; i < month; i++) {
                    this.monthList.push((i + 1) + "月")

                    let mon = this.addZero(i + 1);
                    let wdMonth = wdList.find((wd) => {
                        return wd.wnvMonth.substring(5,8) === mon
                    })
                    let wd = wdMonth ? Number(wdMonth.indexOptions) : 0;
                    this.wdList.push(wd)

                    let jslMonth = jslList.find((wd) => {
                        return wd.wnvMonth.substring(5,8) === mon
                    })
                    let jsl = jslMonth ? Number(jslMonth.indexOptions) : 0;
                    this.jslList.push(jsl)

                    let wmslMonth = wmslList.find((wd) => {
                        return wd.wnvMonth.substring(5,8) === mon
                    })
                    let wmsl = wmslMonth ? Number(wmslMonth.indexOptions) : 0;
                    this.wmslList.push(wmsl)
                    this.wmslData.push({
                        number: wmsl,
                        month: wmslMonth ? wmslMonth.wnvMonth : 0
                    })


                    let hnslMonth = hnslList.find((wd) => {
                        return wd.wnvMonth.substring(5,8) === mon
                    })
                    let hnsl = hnslMonth ? Number(hnslMonth.indexOptions) : 0;
                    this.hnslList.push(hnsl)
                    this.hnslData.push({
                        number: hnsl,
                        month: hnslMonth ? hnslMonth.wnvMonth : 0
                    })

                    let blslMonth = blList.find((wd) => {
                        return wd.wnvMonth.substring(5,8) === mon
                    })
                    let blsl = blslMonth ? Number(blslMonth.indexOptions) : 0;
                    this.blslList.push(blsl)
                    this.blslData.push({
                        number: blsl,
                        month: blslMonth ? blslMonth.wnvMonth : 0
                    })

                    let fxsl = blslMonth ? Number(blslMonth.wnvResult) : 0;
                    fxList.push(fxsl)

                    this.scoreData.push({
                        number: wfy.accMul(Number(blslMonth && blslMonth.indexOptions || 0),Number(blslMonth && wfy.accDiv(Number(blslMonth.indexWeight),100) || 0)) + wfy.accMul(Number(hnslMonth && hnslMonth.indexOptions || 0),Number(hnslMonth && wfy.accDiv(Number(hnslMonth.indexWeight),100) || 0)) + wfy.accMul(Number(wmslMonth && wmslMonth.indexOptions || 0),Number(wmslMonth && wfy.accDiv(Number(wmslMonth.indexWeight),100) || 0)),
                        month: blslMonth ? blslMonth.wnvMonth : 0
                    })
                }
                // console.log("🚀 ~ this.monthList", this.monthList)
                // console.log("🚀 ~ this.wdList", this.wdList)
                // console.log("🚀 ~ this.jslList", this.jslList)
                // console.log("🚀 ~ this.wmslList", this.wmslList)
                // console.log("🚀 ~ this.hnslList", this.hnslList)
                this.maxWd = Math.max(...this.wdList);
                console.log("🚀 ~ maxWd", this.maxWd)

                this.maxJsl = Math.max(...this.jslList);
                console.log("🚀 ~ maxJsl", this.maxJsl)

                this.maxWm = Math.max(...this.wmslList);
                console.log("🚀 ~ maxWm", this.maxWm)

                this.maxHn = Math.max(...this.hnslList);
                console.log("🚀 ~ maxHn", this.maxHn)

                let wmslFind = data.find((item) => {
                    return item.indexDesc === "蚊媒数量" && item.wnvMonth === sessionStorage.wnvPdfMonth;
                })
                let hnslFind = data.find((item) => {
                    return item.indexDesc === "候鸟数量" && item.wnvMonth === sessionStorage.wnvPdfMonth;
                })
                let blFind = data.find((item) => {
                    return item.indexDesc === "全球WNV病例数量" && item.wnvMonth === sessionStorage.wnvPdfMonth;
                })
                console.log("🚀 ~ blFind", blFind)
                let wmScore = wmslFind ? wfy.accMul(Number(wmslFind.indexOptions),wfy.accDiv(Number(wmslFind.indexWeight),100)).toFixed(2) : 0;
                let hnScore = hnslFind ? wfy.accMul(Number(hnslFind.indexOptions),wfy.accDiv(Number(hnslFind.indexWeight),100)).toFixed(2) : 0;
                let blScore = blFind ? wfy.accMul(Number(blFind.indexOptions),wfy.accDiv(Number(blFind.indexWeight),100)).toFixed(2) : 0;
                this.thisMonthScore = ((Number(wmScore)) + (Number(hnScore)) + (Number(blScore))).toFixed(2);
                this.tableData = [
                    {
                        project: '蚊媒数量',
                        number: wmslFind ? wmslFind.indexOptions : 0,
                        score: wmScore
                    }, {
                        project: '候鸟数量',
                        number: hnslFind ? hnslFind.indexOptions : 0,
                        score: hnScore
                    }, {
                        project: '西尼罗热发病数',
                        number: blFind ? blFind.indexOptions : 0,
                        score: blScore
                    }, {
                        project: '西尼罗热输入风险计分',
                        number: '',
                        score: this.thisMonthScore
                    }
                ]

                this.monthList.forEach((item,idx) => {
                    this.tableDataYear.push({
                        month: item,
                        wm: this.wmslList[idx],
                        hn: this.hnslList[idx],
                        bl: this.blslList[idx],
                        fx: fxList[idx]
                    })
                })


                // 排序逻辑
                // 蚊媒排序
                this.wmslData = this.wmslData.sort(wfy.sortBy('number'))
                let wmResult = this.getSeq(this.wmslData);
                console.log("🚀 ~ wmResult", wmResult)
                this.monthWmSeq = wmResult.monthWmSeq;
                this.beforeWmStr = wmResult.beforeWmStr;
                this.afterWmStr = wmResult.afterWmStr;
                // 候鸟排序
                this.hnslData = this.hnslData.sort(wfy.sortBy('number'))
                let hnResult = this.getSeq(this.hnslData);
                console.log("🚀 ~ hnResult", hnResult)
                this.monthHnSeq = hnResult.monthWmSeq;
                this.beforeHnStr = hnResult.beforeWmStr;
                this.afterHnStr = hnResult.afterWmStr;
                // 病例排序
                this.blslData = this.blslData.sort(wfy.sortBy('number'))
                let blResult = this.getSeq(this.blslData);
                console.log("🚀 ~ blResult", blResult)
                this.monthBlSeq = blResult.monthWmSeq;
                this.beforeBlStr = blResult.beforeWmStr;
                this.afterBlStr = blResult.afterWmStr;

                console.log("🚀 ~ this.this.scoreData", this.scoreData)
                // 分数排序
                this.scoreData = this.scoreData.sort(wfy.sortBy('number'))
                let scoreResult = this.getSeq(this.scoreData);
                console.log("🚀 ~ scoreResult", scoreResult)
                this.monthScoreSeq = scoreResult.monthWmSeq;
                this.beforeScoreStr = scoreResult.beforeWmStr;
                this.afterScoreStr = scoreResult.afterWmStr;

                this.totalBl = this.getTotal(this.blslData);
                this.totalWm = this.getTotal(this.wmslData);
                this.totalHn = this.getTotal(this.hnslData);
                this.totalScore = this.getTotal(this.scoreData);

                this.getList();
                this.initCharts1();
                this.initCharts2();
                this.initCharts3();
            })
        },
        getTotal(slData){
            let total = 0;
            slData.forEach((item,index) => {
                total += Number(item.number)
            })
            return total.toFixed(2);
        },
        getSeq(slData){
            let monthWmSeq = 0;
            slData.forEach((item,index) => {
                if(item.month === sessionStorage.wnvPdfMonth){
                    // console.log("🚀 ~ item,index", item,index)
                    monthWmSeq = (index + 1)
                }
            })
            let beforeWmMonth = slData.filter((item,index) => {
                return index < monthWmSeq - 1
            })
            let beforeWm = [];
            beforeWmMonth.forEach((item) => {
                if(item.month !== 0){
                    beforeWm.push(item.month.substring(5,8))
                }
            })
            let beforeWmStr = beforeWm.join("、");

            let afterWmMonth = slData.filter((item,index) => {
                return index > monthWmSeq - 1
            })
            let afterWm = [];
            afterWmMonth.forEach((item) => {
                if(item.month !== 0){
                    afterWm.push(item.month.substring(5,8))
                }
            })
            let afterWmStr = afterWm.join("、");
            return {
                monthWmSeq,
                beforeWmStr,
                afterWmStr
            }
        },

        getSeqYear(slData){
            let monthWmSeq = 0;
            // console.log("🚀 ~ sessionStorage.wnvPdfMonth.substring(0,4)", sessionStorage.wnvPdfMonth.substring(0,4))
            slData.forEach((item,index) => {
                if(item.wnvYear === sessionStorage.wnvPdfMonth.substring(0,4)){
                    // console.log("🚀 ~ item,index", item,index)
                    monthWmSeq = (index + 1)
                }
            })
            let beforeWmMonth = slData.filter((item,index) => {
                return index < monthWmSeq - 1
            })
            let beforeWm = [];
            beforeWmMonth.forEach((item) => {
                if(item.wnvYear !== 0){
                    beforeWm.push(item.wnvYear)
                }
            })
            let beforeWmStr = beforeWm.join("、");

            let afterWmMonth = slData.filter((item,index) => {
                return index > monthWmSeq - 1
            })
            let afterWm = [];
            afterWmMonth.forEach((item) => {
                if(item.wnvYear !== 0){
                    afterWm.push(item.wnvYear)
                }
            })
            let afterWmStr = afterWm.join("、");
            console.log("🚀 ~ afterWmStr", afterWmStr)
            return {
                monthWmSeq : slData.length + 1 - monthWmSeq,
                beforeWmStr,
                afterWmStr
            }
        },
        getSeqMonth(slData){
            let monthWmSeq = 0;
            // console.log("🚀 ~ sessionStorage.wnvPdfMonth.substring(0,4)", sessionStorage.wnvPdfMonth.substring(0,4))
            slData.forEach((item,index) => {
                if(item.wnvMonth === sessionStorage.wnvPdfMonth){
                    // console.log("🚀 ~ item,index", item,index)
                    monthWmSeq = (index + 1)
                }
            })
            let beforeWmMonth = slData.filter((item,index) => {
                return index < monthWmSeq - 1
            })
            let beforeWm = [];
            beforeWmMonth.forEach((item) => {
                if(item.wnvMonth !== 0){
                    beforeWm.push(item.wnvMonth.substring(0,4))
                }
            })
            let beforeWmStr = beforeWm.join("、");

            let afterWmMonth = slData.filter((item,index) => {
                return index > monthWmSeq - 1
            })
            let afterWm = [];
            afterWmMonth.forEach((item) => {
                if(item.wnvYear !== 0){
                    afterWm.push(item.wnvMonth.substring(0,4))
                }
            })
            let afterWmStr = afterWm.join("、");
            console.log("🚀 ~ afterWmStr", afterWmStr)
            return {
                monthWmSeq : slData.length + 1 - monthWmSeq,
                beforeWmStr,
                afterWmStr
            }
        },
        getList(){
            var loading = this.$loading();
            this.$http({
                url: this.$http.adornUrl(`/admin/wnv/queryWnv`),
                method: 'post',
                data: this.$http.adornData({
                    wnvMonth: sessionStorage.wnvPdfMonth
                })
            }).then(({ data }) => {
                console.log('🚀 ~ 查询当月是否有', data)
                loading.close();
                this.thisMonth = data.wnvMonth.substring(5,8);
                this.thisYear = data.wnvMonth.substring(0,4);
                this.wnvResult = data.wnvResult;
                let thisMonthWm = data.wnvDtlList.find((item) => {
                    return item.indexDesc === "蚊媒数量"
                })
                this.thisMonthWm = thisMonthWm.indexOptions;
                let thisMonthHn = data.wnvDtlList.find((item) => {
                    return item.indexDesc === "候鸟数量"
                })
                this.thisMonthHn = thisMonthHn.indexOptions;
                let thisMonthBl = data.wnvDtlList.find((item) => {
                    return item.indexDesc === "全球WNV病例数量"
                })
                this.thisMonthBl = thisMonthBl.indexOptions;


            })
        },
        initCharts1(){
            let myChart = echarts.getInstanceByDom(document.getElementById("charts1"))
            if (myChart == null) {
                myChart = echarts.init(document.getElementById('charts1'))
            }
            // 绘制图表
            myChart.setOption({
                color: ['#5470C6', '#91CC75', '#409EFF'],
                title: {
                    text: '蚊媒数量模型', // 主标题文本
                    left: 'left', // 标题水平位置
                    textStyle: { // 主标题样式
                        color: '#000000'
                    }
                },
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'cross',
                        crossStyle: {
                            color: '#999'
                        }
                    }
                },
                grid: {
                    left: '15%',    // 距离左边的距离可以是像素值或者百分比
                    right: '10%',   // 距离右边的距离
                    top: '15%',     // 距离顶部的距离
                    bottom: '10%'   // 距离底部的距离
                },
                toolbox: {

                },
                legend: {
                    data: ['温度', '降水量','蚊媒数量'],
                    left: "right"
                },
                xAxis: [
                    {
                        type: 'category',
                        data: this.monthList,
                        axisPointer: {
                            type: 'shadow'
                        }
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        name: '温度',
                        min: 0,
                        max: this.maxWd,
                        interval: 5,
                        position: 'left',
                        offset: 50, // y轴位置的偏移量
                        axisLine: {
                            lineStyle: {
                                color: '#5470C6'
                            }
                        },
                        axisLabel: {
                            formatter: '{value} ℃'
                        }
                    },
                    {
                        type: 'value',
                        name: '降水量',
                        min: 0,
                        max: this.maxJsl,
                        interval: 50,
                        position: 'left',
                        axisLine: {
                            lineStyle: {
                                color: '#91CC75'
                            }
                        },
                        axisLabel: {
                            formatter: '{value} ml'
                        }
                    },
                    {
                        type: 'value',
                        name: '蚊媒数量',
                        min: 0,
                        max: this.maxWm,
                        interval: 50,
                        position: 'right',
                        axisLine: {
                            lineStyle: {
                                color: '#409EFF'
                            }
                        },
                        axisLabel: {
                            formatter: '{value} 只'
                        }
                    }
                ],
                series: [
                    {
                        name: '温度',
                        type: 'bar',
                        tooltip: {
                            valueFormatter: function (value) {
                                return value + ' ℃';
                            }
                        },
                        yAxisIndex: 0,
                        data: this.wdList
                    },
                    {
                        name: '降水量',
                        type: 'bar',
                        yAxisIndex: 1,
                        tooltip: {
                            valueFormatter: function (value) {
                                return value + ' ml';
                            }
                        },
                        data: this.jslList
                    },
                    {
                        name: '蚊媒数量',
                        type: 'line',
                        yAxisIndex: 2,
                        tooltip: {

                        },
                        data: this.wmslList
                    },

                ]
            })
        },
        initCharts2(){
            let myChart = echarts.getInstanceByDom(document.getElementById("charts2"))
            if (myChart == null) {
                myChart = echarts.init(document.getElementById('charts2'))
            }
            // 绘制图表
            myChart.setOption({
                color: ['#5470C6', '#91CC75', '#409EFF'],
                title: {
                    text: '候鸟数量模型', // 主标题文本
                    left: 'left', // 标题水平位置
                    textStyle: { // 主标题样式
                        color: '#000000'
                    }
                },
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'cross',
                        crossStyle: {
                            color: '#999'
                        }
                    }
                },
                grid: {
                    left: '15%',    // 距离左边的距离可以是像素值或者百分比
                    right: '10%',   // 距离右边的距离
                    top: '15%',     // 距离顶部的距离
                    bottom: '10%'   // 距离底部的距离
                },
                toolbox: {

                },
                legend: {
                    data: ['温度', '降水量','候鸟数量'],
                    left: "right"
                },
                xAxis: [
                    {
                        type: 'category',
                        data: this.monthList,
                        axisPointer: {
                            type: 'shadow'
                        }
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        name: '温度',
                        min: 0,
                        max: this.maxWd,
                        interval: 5,
                        position: 'left',
                        offset: 50, // y轴位置的偏移量
                        axisLine: {
                            lineStyle: {
                                color: '#5470C6'
                            }
                        },
                        axisLabel: {
                            formatter: '{value} ℃'
                        }
                    },
                    {
                        type: 'value',
                        name: '降水量',
                        min: 0,
                        max: this.maxJsl,
                        interval: 50,
                        position: 'left',
                        axisLine: {
                            lineStyle: {
                                color: '#91CC75'
                            }
                        },
                        axisLabel: {
                            formatter: '{value} ml'
                        }
                    },
                    {
                        type: 'value',
                        name: '候鸟数量',
                        min: 0,
                        max: this.maxHn,
                        interval: 50,
                        position: 'right',
                        axisLine: {
                            lineStyle: {
                                color: '#409EFF'
                            }
                        },
                        axisLabel: {
                            formatter: '{value} 只'
                        }
                    }
                ],
                series: [
                    {
                        name: '温度',
                        type: 'bar',
                        tooltip: {
                            valueFormatter: function (value) {
                                return value + ' ℃';
                            }
                        },
                        yAxisIndex: 0,
                        data: this.wdList
                    },
                    {
                        name: '降水量',
                        type: 'bar',
                        yAxisIndex: 1,
                        tooltip: {
                            valueFormatter: function (value) {
                                return value + ' ml';
                            }
                        },
                        data: this.jslList
                    },
                    {
                        name: '蚊媒数量',
                        type: 'line',
                        yAxisIndex: 2,
                        tooltip: {

                        },
                        data: this.hnslList
                    },

                ]
            })
        },
        initCharts3(){
            let myChart = echarts.getInstanceByDom(document.getElementById("charts3"))
            if (myChart == null) {
                myChart = echarts.init(document.getElementById('charts3'))
            }
            // 绘制图表
            myChart.setOption({
                title: {
                    text: '全球西尼罗热发病数', // 主标题文本
                    left: 'left', // 标题水平位置
                    textStyle: { // 主标题样式
                        color: '#000000'
                    }
                },
                tooltip: {
                    trigger: 'axis',
                    axisPointer: {
                        type: 'cross',
                        crossStyle: {
                            color: '#999'
                        }
                    }
                },
                grid: {
                    left: '10%',    // 距离左边的距离可以是像素值或者百分比
                    right: '10%',   // 距离右边的距离
                    top: '15%',     // 距离顶部的距离
                    bottom: '10%'   // 距离底部的距离
                },
                toolbox: {

                },
                legend: {
                    left: "right"
                },
                xAxis: [
                    {
                        type: 'category',
                        data: this.monthList,
                        axisPointer: {
                            type: 'shadow'
                        }
                    }
                ],
                yAxis: [
                    {
                        type: 'value',
                        name: '',
                        min: 0,
                        max: 300,
                        interval: 50,
                        position: 'left',
                        axisLine: {
                            lineStyle: {
                                color: '#5470C6'
                            }
                        }
                    }
                ],
                series: [
                    {
                        name: '病例数量',
                        type: 'line',
                        tooltip: {

                        },
                        data: this.blslList
                    },

                ]
            })
        }

    }
}
</script>
<style lang="scss" scoped>
    .main-box{
        color: #101111;
    }
    .pdf-box{
        width: 100%;
        margin: 0 auto;
    }
    .title{
        height: 80px;
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: bold;
        font-size: 30px;
    }
    .sub-title{
        font-weight: bold;
        font-size: 25px;
        line-height: 60px;
    }
    .th-title{
        font-weight: bold;
        font-size: 22px;
    }
    .zw{
        visibility: hidden;
    }
    .content{
        font-size: 18px;
        line-height: 36px;
    }
</style>
